<?php

/**
 * Description of PersonHomePanelclass
 *
 * @author adhamhelal
 */
class PersonHomePanel extends QPanel{
        protected $mctAddress;

        //Controls
        protected $txtHomeEmail;
        protected $txtHomePhone;
        protected $txtHomePhone2;
        protected $txtHomeMobile;
        protected $txtHomeMobile2;

        public function __construct($objParentObject,$mctAddress, $strControlId = null) {
                
                // Call the Parent
                try {
                        parent::__construct($objParentObject, $strControlId);
                } catch (QCallerException $objExc) {
                        $objExc->IncrementOffset();
                        throw $objExc;
                }

                // Setup Template
                $this->strTemplate = __DOCROOT__.__PERSON__ .  '/tpl/qpanel.tpl.php';
                // Set the Person Meta Conrol
                
                $this->mctAddress=$mctAddress;
                // Call MetaControl's methods to create qcontrols based on ComSchool's data fields
                $this->txtHomePhone = $this->mctAddress->txtHomePhone_Create();
                $this->txtHomePhone->SetParentControl($this);

                $this->txtHomePhone2 = $this->mctAddress->txtHomePhone2_Create();
                $this->txtHomePhone2->SetParentControl($this);

                $this->txtHomeMobile = $this->mctAddress->txtHomeMobile_Create();
                $this->txtHomeMobile->SetParentControl($this);

                $this->txtHomeMobile2 = $this->mctAddress->txtHomeMobile2_Create();
                $this->txtHomeMobile2->SetParentControl($this);

                $this->txtHomeEmail  = $this->mctAddress->txtHomeEmail_Create();
                $this->txtHomeEmail->SetParentControl($this);
    }

    public function Validate() {
        $Error = false;

        if ( ValidateNumberCtl($this->txtHomePhone) )   $Error=true;
        if ( ValidateNumberCtl($this->txtHomePhone2) )  $Error=true;
        if ( ValidateNumberCtl($this->txtHomeMobile) )  $Error=true;
        if ( ValidateNumberCtl($this->txtHomeMobile2) ) $Error=true;
        if ( ValidateEmailCtl($this->txtHomeEmail) )   $Error=true;

        $blnFocused = false;
        foreach ($this->GetChildControls()  as $objControl) {
              if ( !is_null($objControl->Warning) )  {
                    if (!$blnFocused) {
                            $objControl->Focus();
                            $blnFocused = true;
                    }
                    $objControl->Blink();
              }
        }
        return $Error;
    }
}
?>
